package com.jz.community.moduleshopping.address.ui;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.jz.community.basecomm.base.BaseMvpActivity;
import com.jz.community.basecomm.mvp.BaseMvpPresenter;
import com.jz.community.basecomm.utils.CommUtils;
import com.jz.community.moduleshopping.R;
import com.jz.community.moduleshopping.R2;
import com.jz.community.moduleshopping.utils.SpUtils;

import butterknife.BindView;

/**
 * Created by Tony.Fan on 2018/5/3 09:37
 * <p>
 * 更新用户信息
 */
public class UpdateUserMsgActivity extends BaseMvpActivity {
    @BindView(R2.id.tv_back)
    ImageView tvBack;
    @BindView(R2.id.tv_title)
    TextView tvTitle;
    @BindView(R2.id.commit_order_toolbar)
    Toolbar commitOrderToolbar;
    @BindView(R2.id.linkman_name)
    EditText linkmanName;
    @BindView(R2.id.user_tel_number)
    EditText userTelNumber;
    @BindView(R2.id.button_commit)
    Button buttonCommit;

    @Override
    protected int getContentView() {
        return R.layout.module_shopping_activity_edit_user_base_message;
    }

    @Override
    protected BaseMvpPresenter createPresenter() {
        return null;
    }

    @Override
    protected void initView() {
        setImmersionBar(commitOrderToolbar);
        tvTitle.setText("修改个人信息");
        linkmanName.setText(SpUtils.getInstance().getConsigneeName(this));
        userTelNumber.setText(SpUtils.getInstance().getConsigneePhone(this));
    }

    @Override
    protected void addListener() {
        tvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        buttonCommit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CommUtils.hideKeyboard(v,UpdateUserMsgActivity.this);
                SpUtils.getInstance().setConsigneeName(UpdateUserMsgActivity.this, linkmanName.getText().toString());
                SpUtils.getInstance().setConsigneePhone(UpdateUserMsgActivity.this, userTelNumber.getText().toString());
                setResult(RESULT_OK);
                finish();
            }
        });
    }
}
